//
//  LGCommenSettingController.m
//  微博
//
//  Created by MS on 15-12-27.
//  Copyright (c) 2015年 MS. All rights reserved.
//

#import "LGCommenSettingController.h"
#import "BasicSetting.h"
#import "LGFontSettingController.h"
@interface LGCommenSettingController ()
@property (nonatomic,weak) LGItem * font;
@end

@implementation LGCommenSettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setUpGroup0];
    [self setUpGroup1];
    [self setUpGroup2];
    [self setUpGroup3];
    [self setUpGroup4];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fontChange:) name:LGFontSizeChangeNote object:nil];
}

-(void)fontChange:(NSNotification *)note
{
    
    self.font.subTitle = [LGUserDefaults objectForKey:LGFontSizeKey];
    
    [self.tableView reloadData];
}

-(void) setUpGroup0
{
    LGItem * readMode = [LGItem itemWithTitle:@"阅读模式" subTitle:@"有图模式"];
    
    LGItem * font = [LGItem itemWithTitle:@"字体大小"];
    self.font = font;
    font.jumpClass = [LGFontSettingController class];
    
    NSString * fontSize = [LGUserDefaults objectForKey:LGFontSizeKey];
    if (fontSize==nil) {
        fontSize = @"中";
    }
    font.subTitle = fontSize;
    
    LGSwitchItem * display = [LGSwitchItem itemWithTitle:@"显示备注"];
    
    LGGroups * group = [[LGGroups alloc] init];
    group.items = @[readMode,font,display];
    [self.groups addObject:group];
    
}
-(void) setUpGroup1
{
    LGArrowItem * pic = [LGArrowItem itemWithTitle:@"图片质量"];
    
    LGGroups * group = [[LGGroups alloc] init];
    group.items = @[pic];
    [self.groups addObject:group];
    
}
-(void) setUpGroup2
{
    LGSwitchItem * vol = [LGSwitchItem itemWithTitle:@"声音"];

    
    LGGroups * group = [[LGGroups alloc] init];
    group.items = @[vol];
    [self.groups addObject:group];
    
}
-(void) setUpGroup3
{
     LGItem * language = [LGItem itemWithTitle:@"多语言环境" subTitle:@"跟随系统"];
    
    LGGroups * group = [[LGGroups alloc] init];
    group.items = @[language];
    [self.groups addObject:group];
    
}
-(void) setUpGroup4
{
    LGArrowItem * picCache = [LGArrowItem itemWithTitle:@"清空图片缓存"];
    picCache.subTitle=@"0kB";
    LGGroups * group = [[LGGroups alloc] init];
    group.items = @[picCache];
    [self.groups addObject:group];
    
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
